<template>
	<view class="main-page">
		<view class="row-container" style="height: 110rpx;width: 100%;background: white;">
			<view class="single-tab" @click="switchListType(0)">
				<text v-if="listType == 0" class="font-333-32 font-bold">待提交</text>
				<text v-if="listType != 0" class="font-333-32">待提交</text>
				<view v-if="listType == 0" class="chosen-flag"></view>
			</view>
			<view class="single-tab" @click="switchListType(1)">
				<text v-if="listType == 1" class="font-333-32 font-bold">待返现</text>
				<text v-if="listType != 1" class="font-333-32">待返现</text>
				<view v-if="listType == 1" class="chosen-flag"></view>
			</view>
			<view class="single-tab" @click="switchListType(2)">
				<text v-if="listType == 2" class="font-333-32 font-bold">已返现</text>
				<text v-if="listType != 2" class="font-333-32">已返现</text>
				<view v-if="listType == 2" class="chosen-flag"></view>
			</view>
			<view class="single-tab" @click="switchListType(3)">
				<text v-if="listType == 3" class="font-333-32 font-bold">已失效</text>
				<text v-if="listType != 3" class="font-333-32">已失效</text>
				<view v-if="listType == 3" class="chosen-flag"></view>
			</view>
		</view>
		<text class="hint-box">须在规定时间内提交订单，否则名额失效无返现</text>
		<view class="column-container" style="width: 100%;">
			<view class="list-box" v-if="orderList.length > 0">
				<view class="list-item" v-for="(item , index) in orderList" :key="index"
				@click="gotoOrderDetail(item)">
					<image class="item-bg" src="../../static/order/bg_order_red.png"></image>
					<view class="left-box">
						<view class="row-container">
							<text class="meituan-tag">美团</text>
							<text class="font-6d3320-22">待提交</text>
						</view>
						<view class="row-container" style="margin-top: 10rpx;">
							<text class="font-ff4015-32" style="margin-top: 10rpx;font-weight: 600;">¥</text>
							<text class="font-ff4015-66" style="font-weight: 600;">28</text>
						</view>
						<text class="give-up" @click.stop="clickCancelTask">放弃名额</text>
					</view>
					<view class="right-box">
						<text class="font-6d3320-30" style="font-weight: 600;">老虎斑剁椒鱼头(环宇城店)</text>
						<view class="row-container" style="margin-top: 4rpx;">
							<text class="font-6d3320-24" style="font-weight: 600;">本店通用，满55返28</text>
							<text class="check-task">查看任务</text>
						</view>
						<text class="font-b57d6b-24" style="margin-top: 4rpx;">有效期剩余：3时59分41秒</text>
						<text class="font-b57d6b-24" style="margin-top: 4rpx;">将于 2024-01-04 19:31:26 过期</text>
						<text class="font-b57d6b-24" style="margin-top: 4rpx;">请尽快提交截图领餐补，否则过期作废</text>
					</view>
				</view>
			</view>
			<NoData hint="暂无内容，快去抢名额吧！" v-else></NoData>
		</view>
		
		<view class="window-main" v-if="showCancelOrderWindow">
			<view class="cancel-window">
				<image class="header-bg" src="../../static/common/bg_shadow_window.png"></image>
				<image class="hint-ic" src="../../static/common/ic_warn_yellow.png"></image>
				<text class="font-333-36 font-bold" style="margin-bottom: 10rpx;">您确定要放弃这个名额吗?</text>
				<text class="font-666-28">放弃名额后，将无法获得该商户返现红包</text>
				<text class="shop-name">逸甜时光 (生日蛋糕)</text>
				<view class="btn-box">
					<text class="cancel-btn" @click="showCancelOrderWindow = false">取消</text>
					<text class="confirm-btn" @click="handleConfirmCancel">确定</text>
				</view>
			</view>
		</view>
		
		<view class="window-main" v-if="showCancelSuccessWindow">
			<view class="cancel-window">
				<image class="header-bg" src="../../static/common/bg_shadow_window.png"></image>
				<image class="hint-ic" src="../../static/common/ic_success.png"></image>
				<text class="font-333-36 font-bold">已取消本名额，可再抢其它的</text>
				<text class="full-btn" @click="showCancelSuccessWindow = false">确定</text>
			</view>
		</view>
		
		
	</view>
</template>

<script>
	import NoData from '../../components/NoData.vue'
	
	export default {
		data() {
			return {
				listType : 0,
				orderList:[1,2,3],
				showCancelOrderWindow:false,
				showCancelSuccessWindow:false,
			}
		},
		
		onLoad() {
			let that = this
			uni.$on("switchOrderList" , (data)=>{
				that.listType = data
			})
		},
		
		components:{
			NoData
		},
		
		methods: {
			switchListType(type){
				this.listType = type
			},
			
			clickCancelTask(){
				this.showCancelOrderWindow = true
			},
			
			gotoOrderDetail(item){
				uni.navigateTo({
					url:'./orderDetail'
				})
			},
			
			//确认取消订单
			handleConfirmCancel(){
				this.showCancelOrderWindow = false
				this.showCancelSuccessWindow = true
			}
		}
	}
</script>

<style lang="scss">
	.single-tab{
		position: relative;
		height: 100rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		flex-grow: 1;
		
		.chosen-flag{
			width: 96rpx;
			height: 8rpx;
			background: linear-gradient(90.04deg, #FFC01F 0.04%, rgba(255, 209, 0, 0) 101.53%);
			position: absolute;
			bottom: 26rpx;
		}
	}
	
	.hint-box{
		width: 100%;
		height: 70rpx;
		background: #EEEEEE;
		text-align: center;
		line-height: 70rpx;
		color: #333333;
		font-size: 26rpx;
	}
	
	.list-box{
		display: flex;
		flex-direction: column;
		width: calc(100% - 68rpx);
		align-items: center;
		margin-top: 20rpx;
		margin-left: 34rpx;
		
		.list-item{
			display: flex;
			flex-direction: row;
			align-items: center;
			width: 100%;
			height: 237rpx;
			position: relative;
			margin-bottom: 20rpx;
			
			.item-bg{
				width: 100%;
				height: 237rpx;
				position: absolute;
				top:0
			}
			
			.left-box{
				width: 192rpx;
				height: 233rpx;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;
				z-index: 40;
				flex-shrink: 0;
				
				.meituan-tag{
					padding: 1rpx 10rpx;
					background: #FFC736;
					border-radius: 10rpx;
					color: #333333;
					font-size: 20rpx;
					font-weight: 600;
					margin-right: 10rpx;
				}
				
				.ele-tag{
					padding: 1rpx 7rpx;
					background: #318DF8;
					border-radius: 10rpx;
					color: white;
					font-size: 20rpx;
					font-weight: 600;
					margin-right: 10rpx;
				}
				
				.give-up{
					width: 140rpx;
					height: 48rpx;
					background: linear-gradient(90deg, #443323 0%, #282421 100%);
					border-radius: 24rpx;
					color: #FFDBBB;
					font-size: 24rpx;
					font-weight: 600;
					margin-top: 10rpx;
					text-align: center;
					line-height: 48rpx;
				}
			}
			
			.right-box{
				display: flex;
				flex-direction: column;
				margin: 0rpx 25rpx;
				flex-shrink: 0;
				z-index: 40;
				
				.check-task{
					padding: 3rpx 12rpx;
					font-size: 20rpx;
					color: #6D3320;
					font-weight: 600;
					border: #6D3320 1rpx solid;
					margin-left: 20rpx;
					border-radius: 24rpx;
				}
				
			}
		}
	}
	
	.cancel-window{
		width: calc(100% - 148rpx);
		background: white;
		display: flex;
		flex-direction: column;
		position: relative;
		border-radius: 30rpx;
		align-items: center;
		
		.header-bg{
			width: 100%;
			height: 220rpx;
			position: absolute;
			top: 0;
		}
		
		.hint-ic{
			width: 108rpx;
			height: 108rpx;
			margin-bottom: 20rpx;
			z-index: 110;
			margin-top: 50rpx;
		}
		
		.shop-name{
			width: calc(100% - 88rpx);
			height: 74rpx;
			border-radius: 10rpx;
			background: rgba(255, 209, 0, 0.1);
			margin-top: 30rpx;
			margin-bottom: 44rpx;
			text-align: center;
			line-height: 74rpx;
			color: #FF621F;
			font-size: 28rpx;
			font-weight: 600;
		}
		
		.btn-box{
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: space-between;
			width: calc(100% - 88rpx);
			margin-bottom: 44rpx;
			
			.cancel-btn{
				flex-grow: 1;
				height: 88rpx;
				background: #F5F5F5;
				margin-right: 15rpx;
				color: #333333;
				border: #E0E0E0 solid 1rpx;
				text-align: center;
				line-height: 88rpx;
				border-radius: 10rpx;
				font-size: 32rpx;
			}
			
			.confirm-btn{
				flex-grow: 1;
				height: 88rpx;
				background: #FFD100;
				margin-left: 15rpx;
				font-weight: 600;
				color: #333333;
				text-align: center;
				line-height: 88rpx;
				border-radius: 10rpx;
				font-size: 32rpx;
			}
		}
		
		.full-btn{
			width: calc(100% - 44rpx);
			height: 88rpx;
			background: #FFD100;
			font-weight: 600;
			color: #333333;
			text-align: center;
			line-height: 88rpx;
			border-radius: 10rpx;
			font-size: 32rpx;
			margin: 44rpx;
		}
		
	}
	
</style>
